﻿using System;

namespace AgFractal.Fractals
{
    public class Bambi : AbstractFractal
    {
        public Bambi()
        {
            ID = new Guid("43103176-B193-4536-AB85-0F8226404D99");
            Name = Description = "Bambi";
            R1 = -2.25; I1 = 1.5; R2 = 2.25; I2 = -1.5;

            var seedParam = new FractalParameter { Name = "seed", ComplexValue = seed };
            seedParam.PropertyChanged += (s, e) => seed = seedParam.ComplexValue;
            parameter.Add(seedParam);
        }

        private Complex seed = new Complex(0.3141, -0.5);
        protected override short Calculate(double r, double i, short MaxIteration)
        {
            Complex z = new Complex(r, i).Sqr();            
            short j = 0;
            do
            {
                z = z.Sqr() + seed;
                j++; 
            } while ((z.Abs2() < 4) && (j < MaxIteration));
            return j;
        }
    }
}